package com.itany.corejava.code10_io.字符流;

import java.io.*;

/**
 * @author MissChen
 * @date 2024年03月11日 14:54
 */
public class Test03_转换流 {
    public static void main(String[] args) {
        try (

                FileInputStream in = new FileInputStream("aaa.txt");

                //定义转换流可以指定编码，如果未指定，则使用默认的字符编码
                // InputStreamReader reader = new InputStreamReader(in);
                InputStreamReader reader = new InputStreamReader(in,"UTF-8");

                //缓冲流
                BufferedReader br=new BufferedReader(reader);

                //可以使用指定编码写入文件
                PrintWriter out=new PrintWriter("abb.txt","UTF-8");




        ) {
            String line=null;
            while((line=br.readLine())!=null){
                // System.out.println(line);
                out.println(line);
            }


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
